/**
 * 
 */
package de.cbf.cam.dsa.facet.armor.editor;

import static de.cbf.util.ui.test_support.ConstantsSWTBOTUtil.DEFAULT_SWT_BOT_KEY;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import de.cbf.cam.dsa.facet.armor.helper.ZoneFactors;
import de.cbf.util.ui.composites.CompositeTableEdit;
import de.cbf.util.ui.test_support.ConstantsSWTBOTUtil;

/**
 * @author salter
 *
 */
public class CompositeEditZoneFactors extends CompositeTableEdit<ZoneFactors> {

	public static final String TEXT_BT_RESET = "Reset";
	public static final String TEXT_HEADER	 = "ZoneFactors";

	public CompositeEditZoneFactors(Composite parent, int style) {
		super(ZoneFactors.class, parent, style);
	}
	
	protected void createHeaderLabel(Composite parent) {
		lbl_Header = new Label(this, SWT.LEFT);
		lbl_Header.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		lbl_Header.setText(TEXT_HEADER);		
	}
	
	protected void buildButtons(Composite parent) {		
		bt_Remove = new Button(parent, SWT.PUSH);
		bt_Remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
		bt_Remove.setText(TEXT_BT_RESET);
		bt_Remove.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTUtil.TABLE_EDIT_BUTTON_REMOVE);
		bt_Remove.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				fireUICommand(CMD_REMOVE, (Object[])null);
			}
		});		
	}
	
	public int getUIButtonState(){
		int result = 0;		
		if(bt_Remove.isEnabled()){
			result &= BT_STATE_REMOVE;
		}		
		return result;
	}

	public void setUIButtonState(int stateMask){		
		bt_Remove.setEnabled((stateMask & BT_STATE_REMOVE)	!=0);		
	}
	
	protected GridData createTableLayoutData(){
		GridData gd_Table = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);		
		gd_Table.widthHint = 60;
		return gd_Table;
	}

}
